<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Manage\Model;
use Think\Model;
use User\Api\UserApi;

/**
 * 消费记录model 
 */
class RecordsModel extends Model{

    /* 用户模型自动完成 */
    protected $_auto = array(
    );
    
    //消费类型
    protected $type = array(
        '1'=>'消费',
        '2'=>'返利',
        '3'=>'充值',
        '4'=>'预存',
        '5'=>'退款',
    );
    
    /**
     * 获取消费类型值
     * @param int $key
     * @return string 消费类型值
     */
    public function getType($key){
    	//如果当前的值不存在，那么返回空字符串
    	if(!array_key_exists($key, $this->type)){
    	    return '';
    	}
        return $this->type[$key];
    }

    
    /**
     * 添加一条消费记录
     * @param int $type 消费类型
     * @param float $fee 消费金额
     * @param float $money 还剩下的钱
     * @param string $desc 消费描述
     */
    public function recordsAdd($uid,$type,$fee,$money,$desc){
    	$data = array(
    			'uid'=>$uid,
    			'auid'=>UID,
    			'type'=>$type,
    			'cost'=>$fee,
    			'last'=>$money,
    			'desc'=>$desc,
    			'createtime'=>time()
    	);
    	$this->add($data);
    }

}
